"use strict";
cc._RF.push(module, '6a442Xn4CtKroILj7jPXMlu', 'GameData');
// script/libs/GameData.ts

"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var Constants_1 = require("./Constants");
var HelperMgr_1 = require("./HelperMgr");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var GameData = /** @class */ (function () {
    function GameData() {
        //全局数据 ： 保存
        /**游戏关卡 */
        this.gameStage = 1;
        /**游戏解锁最大关卡 */
        this.gameMaxStage = 1;
        /**玩家正常模式游戏分数 */
        this.playScores = [];
        /**玩家疯狂游戏分数 */
        this.playCrazyScores = [];
        /**玩家当前分数 */
        this.playScore = 0;
        /**玩家当前棒子 */
        this.playRod = 0;
        /**玩家当前鱼饵 */
        this.playStosh = 1;
        /**玩家当前拥有棒子索引 */
        this.playRods = [];
        /**玩家当前拥有鱼饵索引 */
        this.playStoshs = [];
        /**玩家当前金币 */
        this.playGold = 0;
        /**签到的日期 */
        this.signDays = [];
        /**今日是否签到 */
        this.isSignedToday = false;
        /**商店兑换物品种类 */
        this.shopIsStosh = false;
        /**商店兑换物品索引 */
        this.shopIndex = 0;
        //临时数据 ： 不保存
        /**游戏模式 true:正常模式,false:乱打模式 */
        this.gameModel = true;
        /**玩家是否点击了返回主页 */
        this.gameBack = false;
        this.gameScore = 0;
        this.gameChance = 0;
        this.init();
        GameData_1._instance = this;
    }
    GameData_1 = GameData;
    Object.defineProperty(GameData, "instance", {
        get: function () {
            if (!GameData_1._instance) {
                new GameData_1();
            }
            ;
            return GameData_1._instance;
        },
        enumerable: false,
        configurable: true
    });
    GameData.prototype.init = function () {
        this.loadData();
    };
    GameData.prototype.loadData = function () {
        var day = (new Date()).getDate();
        this.gameStage = JSON.parse(localStorage.getItem("gameStage") || '1');
        this.gameMaxStage = JSON.parse(localStorage.getItem("gameMaxStage") || '1');
        this.playScores = JSON.parse(localStorage.getItem("playScores") || '[0,0,0,0,0]');
        this.playCrazyScores = JSON.parse(localStorage.getItem("playCrazyScores") || '[0,0,0,0,0]');
        this.playRod = JSON.parse(localStorage.getItem("playRod") || '0');
        this.playStosh = JSON.parse(localStorage.getItem("playStosh") || '0');
        this.playGold = JSON.parse(localStorage.getItem("playGold") || '0');
        this.playRods = JSON.parse(localStorage.getItem("playRods") || '[0,0,0]');
        this.playStoshs = JSON.parse(localStorage.getItem("playStoshs") || '[0,0,0]');
        var sinDaysStr = localStorage.getItem("signDays") || '';
        if (sinDaysStr.length > 0) {
            this.signDays = HelperMgr_1.default.splitToNumber(sinDaysStr, ',');
        }
        if (this.signDays.length >= 7) {
            this.signDays = [];
            localStorage.setItem("signDays", "");
        }
        if (sinDaysStr.length <= 0) {
            this.signDays.push(day);
            this.playGold += Constants_1.default.SignReward[0];
        }
        this.isSignedToday = this.signDays.indexOf(day) > -1;
    };
    GameData.prototype.saveData = function () {
        if (this.gameStage > this.gameMaxStage) {
            this.gameMaxStage = this.gameStage;
        }
        localStorage.setItem("gameStage", this.gameStage.toString());
        localStorage.setItem("gameMaxStage", this.gameMaxStage.toString());
        localStorage.setItem("playRod", this.playRod.toString());
        localStorage.setItem("playGold", this.playGold.toString());
        localStorage.setItem("playStosh", this.playStosh.toString());
        localStorage.setItem("playScores", JSON.stringify(this.playScores));
        localStorage.setItem("playCrazyScores", JSON.stringify(this.playCrazyScores));
        localStorage.setItem("playRods", JSON.stringify(this.playRods));
        localStorage.setItem("playStoshs", JSON.stringify(this.playStoshs));
        localStorage.setItem("signDays", this.signDays.join(','));
    };
    var GameData_1;
    GameData._instance = null;
    GameData = GameData_1 = __decorate([
        ccclass
    ], GameData);
    return GameData;
}());
exports.default = GameData;

cc._RF.pop();